package com.wzdigit.wms.wms.controller.inventory;

import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.basic.client.response.Result;
import com.wzdigit.wms.basic.client.response.report.ScanSnResponse;
import com.wzdigit.wms.wms.constant.WmsWareConstant;
import com.wzdigit.wms.wms.service.core.inventory.GoodsSnReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 *  PDA扫描SN
 * Created by zyf on 2021/7/5 9:48
 */
@RestController
@Api(tags = "PDA扫描SN")
@RequestMapping(value = WmsWareConstant.API_VERSION)
public class ScanSnController {
    private final String REQUEST_MODEL = "/scanSn";

    @Autowired
    private GoodsSnReportService snReportService;

    @ApiOperation(value = "获取SN信息", notes = "获取SN信息")
    @ApiResponses({@ApiResponse(code = 500, message = "系统出现异常", response = ErrorEntity.class)})
    @RequestMapping(value = REQUEST_MODEL + "/getInfo", method = RequestMethod.GET)
    public Result<ScanSnResponse> scanSnInfo(
            String goodsSn,
            HttpServletRequest servletRequest, HttpServletResponse servletResponse) {
        try {
            return snReportService.scanSnInfo(goodsSn);
        } catch (Exception ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
}
